﻿using System;
using System.Collections.Generic;
using System.Text;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Security;
using Umi.Crypto.Abstraction.Ciphers;
using Umi.Web.Crypto.Crypto.Aes;
using Umi.Web.Crypto.Crypto.Rsa;
using Umi.Web.Metadatas.Attributes;

namespace Umi.Web.Crypto.Crypto
{
    [Service("cryptoFactory", Scoped = ServiceScoped.Single)]
    public class CryptoFactory : ICryptoFactory
    {
        public ICryptoService CreateCrypto(string name)
        {
            if (name.IndexOf("aes", StringComparison.OrdinalIgnoreCase) >= 0)
                return new AesCryptoService(name);
            if (name.IndexOf("rsa", StringComparison.OrdinalIgnoreCase) >= 0)
                return new RsaCryptoService(name);
            throw new NotImplementedException($"the cipher {name} not implemented");
        }
    }
}
